package com.ngkj.zmfptback.sys.initData.servicie.write.impl;

import com.ngkj.zmfptback.sys.initData.bean.SysDict;
import com.ngkj.zmfptback.sys.initData.mapper.write.DictWriteMapper;
import com.ngkj.zmfptback.sys.initData.servicie.write.DictWriteService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ChenHN
 * @since 2021/12/24 creation
 **/
@Service
@Transactional(propagation = Propagation.REQUIRED)
public class DictWriteServiceImpl implements DictWriteService {

    @Resource
    private DictWriteMapper dictWriteMapper;

    @Override
    public void addDict(SysDict sysDict) {
        sysDict.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        dictWriteMapper.addDict(sysDict);
    }

    @Override
    public void editDict(SysDict sysDict) {
        sysDict.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        dictWriteMapper.editDict(sysDict);
    }

    @Override
    public void deleteDict(Integer id) {
        dictWriteMapper.deleteDict(id);
    }
}
